package com.spic.business.ioc.controller;

import com.spic.business.ioc.domain.IocGoodDays;
import com.spic.business.ioc.service.IIocGoodDaysService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 优良天数IOCController
 *
 * @author spic
 * @date 2022-04-14
 */
@RestController
@RequestMapping("/ioc/days")
public class IocGoodDaysController extends BaseController
{
    @Autowired
    private IIocGoodDaysService iocGoodDaysService;

    /**
     * 查询优良天数IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:days:list")
    @GetMapping("/list")
    public TableDataInfo list(IocGoodDays iocGoodDays)
    {
        startPage();
        List<IocGoodDays> list = iocGoodDaysService.selectIocGoodDaysList(iocGoodDays);
        return getDataTable(list);
    }

    /**
     * 导出优良天数IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:days:export")
//    @Log(title = "优良天数IOC", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IocGoodDays iocGoodDays) throws IOException
    {
        List<IocGoodDays> list = iocGoodDaysService.selectIocGoodDaysList(iocGoodDays);
        ExcelUtil<IocGoodDays> util = new ExcelUtil<IocGoodDays>(IocGoodDays.class);
        util.exportExcel(response, list, "优良天数IOC数据");
    }

    /**
     * 获取优良天数IOC详细信息
     */
//    @PreAuthorize(hasPermi = "ioc:days:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(iocGoodDaysService.selectIocGoodDaysById(id));
    }

    /**
     * 新增优良天数IOC
     */
//    @PreAuthorize(hasPermi = "ioc:days:add")
//    @Log(title = "优良天数IOC", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IocGoodDays iocGoodDays)
    {
        return toAjax(iocGoodDaysService.insertIocGoodDays(iocGoodDays));
    }

    /**
     * 修改优良天数IOC
     */
//    @PreAuthorize(hasPermi = "ioc:days:edit")
//    @Log(title = "优良天数IOC", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IocGoodDays iocGoodDays)
    {
        return toAjax(iocGoodDaysService.updateIocGoodDays(iocGoodDays));
    }

    /**
     * 删除优良天数IOC
     */
//    @PreAuthorize(hasPermi = "ioc:days:remove")
//    @Log(title = "优良天数IOC", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(iocGoodDaysService.deleteIocGoodDaysByIds(ids));
    }
}
